package by.brest.bspc.reporter.jasperreports.connectors;

import com.jaspersoft.mongodb.connection.MongoDbConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

/**
 * This class contains override factory method createConnection() for creating connection to mongoDB database.
 *
 * @date: 02.10.13 16:50
 * @author: Natallia
 */
public class MongoConnectionFactoryImpl implements MongoConnectionFactory {
    private static final Logger LOG = LoggerFactory.getLogger(MongoConnectionFactoryImpl.class);

    private MongoConnection mongoConnection;

    public MongoConnection createConnection(String mongoUri) {
        try {
            LOG.debug(">> mongoURI: " + mongoUri);

            LOG.debug(">> Trying to connect to database.");

            mongoConnection = new MongoConnectionImpl(new MongoDbConnection(mongoUri, null, null));

            LOG.debug(">> Created mongo mongoConnection: " + mongoConnection);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return mongoConnection;
    }
}
